<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>新浪注册</title>
    <style>
        div {
            width: 600px;
            margin: 100px auto;
        }
        
        .message {
            display: inline-block;
            font-size: 12px;
            color: #999;
            background: url(images/mess.png) no-repeat left center;
            padding-left: 20px;
        }
        
        .wrong {
            color: red;
            background-image: url(images/wrong.png);
        }
        
        .right {
            color: green;
            background-image: url(images/right.png);
        }
    </style>
</head>

<body>
    <div class="register">
        <input type="password" class="pwd">
        <p class="message">请输入6~16位密码</p>
    </div>
	<script type="text/javascript">
		var pwd = document.querySelector('.pwd');
		var p = document.querySelector('p');
		pwd.onblur = function(){
			console.log('abc....'+pwd.value);
			if(pwd.value.length<6||pwd.value.length>16){
				p.className = 'message wrong';
				p.innerHTML = '请输入6~16位密码';
			}else{
				p.className = 'message right';
				p.innerHTML = '正确';
			}
		}
	</script>
</body>

</html>